import request from "../../request";

const api = {
    getType: '/admin/type/all',
    update: '/admin/type/update',
    save: '/admin/type/save',
    deleteId: '/admin/type/delete/id=',
    delbatch: '/admin/type/del/batch',
    typeById: '/admin/type/get-type/id=',
    typePage: '/admin/type/page'
}


/**
 * 添加
 * @param data
 * @returns {AxiosPromise}
 */
export function saveTypeData(param){
    return request({
        url: api.save,
        method: 'POST',
        data: param
    })
}


/**
 * 根据id进行删除
 * @returns {AxiosPromise}
 */
export function delTypeByid(id){
  return request({
      url: api.deleteId + id,
      method: 'GET'
  })
}

/**
 * 批量删除
 * @param ids
 * @returns {AxiosPromise}
 */
export function delTypeBatch(ids){
  return request({
      url: api.delbatch,
      method: 'POST',
      data: ids
  })
}

/**
 * 修改
 * @param data
 * @returns {AxiosPromise}
 */
export function updateType(param){
  return request({
      url: api.update,
      method: 'POST',
      data: param
  })
}

/**
 * 查询全部数据
 * @returns {AxiosPromise}
 */
export function getTypeAllData(){
  return request({
      url: api.getType,
      method: 'GET',
  })
}

/**
 * 根据id进行查询
 * @returns {AxiosPromise}
 */
export function getTypeByid(id){
  return request({
      url: api.typeById + id,
      method: 'GET'
  })
}

/**
 * 分页查询
 * @param data
 * @returns {AxiosPromise}
 */
export function getTypePage(param){
  return request({
      url: api.typePage,
      method: 'GET',
      params: param
  })
}